package com.ruoyi.common.core.page;

import lombok.Data;

import java.io.Serializable;


@Data
public class ResponseResult<T> implements Serializable {
    // 状态码
    private int code;
    // 提示信息
    private String msg = "成功";

    private T data;

    public ResponseResult(int code, String msg, T data) {
        // super();
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public ResponseResult(int code) {
        super();
        this.code = code;

    }


    public ResponseResult(int code, String msg) {
        super();
        this.code = code;
        this.msg = msg;
    }


    public ResponseResult(int code, T data) {
        super();
        this.code = code;
        this.data = data;
    }

    public static <T> ResponseResult<T> createBySuccess() {
        return new ResponseResult<T>(0);
    }

    public static <T> ResponseResult<T> createBySuccess(T data) {
        return new ResponseResult<T>(0, data);
    }

    public static <T> ResponseResult<T> createByErrorMessage(String errorMessage) {
        return new ResponseResult<T>(400, errorMessage);
    }

    public static <T> ResponseResult<T> createByErrorMessage(Integer code, String errorMessage) {
        return new ResponseResult<T>(code, errorMessage);
    }


}

